home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / MAILER.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  30KB  |  877 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                 This module was written by Bob Hartman                   */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                   BinkleyTerm Mail Control Routines                      */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*                                                                          */
  20. /*    For complete  details  of the licensing restrictions, please refer    */
  21. /*    to the License  agreement,  which  is published in its entirety in    */
  22. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  23. /*                                                                          */
  24. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  25. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  26. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  27. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  28. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  29. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  30. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  31. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  32. /*                                                                          */
  33. /*                                                                          */
  34. /* You can contact Bit Bucket Software Co. at any one of the following      */
  35. /* addresses:                                                               */
  36. /*                                                                          */
  37. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  38. /* P.O. Box 460398                AlterNet 7:491/0                          */
  39. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  40. /*                                Internet f491.n343.z1.fidonet.org         */
  41. /*                                                                          */
  42. /* Please feel free to contact us at any time to share your comments about  */
  43. /* our software and/or licensing policies.                                  */
  44. /*                                                                          */
  45. /*--------------------------------------------------------------------------*/
  46.  
  47. /* Include this file before any other includes or defines! */
  48.  
  49. #include "includes.h"
  50.  
  51. int poll_node (ADDRP);
  52. int call_node (ADDRP, int);
  53.  
  54. int unattended ()
  55. {
  56. #ifdef MILQ
  57.     REGIONP OldCurWin = CurWinSet( callwin );
  58. #endif
  59.     int no_inbound = 0;
  60.     int j, m;
  61.     long init_timer, t = -1L, t1;                   /* used for the timeouts  */
  62.     long blank_timer;
  63.     struct _key_fnc_hdr *OldKeyFncHdr;
  64.     int done = 1;                                   /* if we exit with this, 
  65.                                                      * get out of BT          */
  66.     HFILE stream;
  67.     USHORT got;
  68.  
  69. #ifdef MILQ
  70.     HWND                OldActvAccel = MilqueActvAccel;
  71.     HWND                OldActvWnd = MilqueActvWnd;
  72.  
  73.     MilqueActvAccel = MilqueMailerAccel;
  74.     MilqueActvWnd = MilqueMailerWnd;
  75.     SetFocus( MilqueMailerActvWnd );
  76. #endif
  77.  
  78.     un_attended = 1;
  79.     clear_statusline ();
  80.  
  81.     comm_bits = BITS_8;
  82.     parity = NO_PARITY;
  83.     stop_bits = STOP_1;
  84.     program_baud ();
  85.  
  86.     OldKeyFncHdr = KbMapSet (&UnattendedKeyFncHdr);
  87.  
  88.     if (fullscreen)
  89.         {
  90.         screen_clear ();
  91.         sb_dirty ();
  92.         }
  93.  
  94.     opening_banner ();
  95.  
  96.     if (fullscreen)
  97.         {
  98.         mailer_banner ();
  99.         }
  100.  
  101.     if ((stream = share_open (PRDCT_PRFX ".BAN", O_RDONLY|O_BINARY, DENY_WRITE)) != -1)
  102.         {
  103.         (void)_dos_read (stream, BBSwelcome, WELCOME_LEN, &got);
  104.         (void) close (stream);
  105.         }
  106.     else
  107.         {
  108.         BBSwelcome[0] = '\0';
  109.         }
  110.  
  111.     /* Initialize the random number generator */
  112.     j = (int) time (NULL);
  113.     srand ((unsigned int) j);
  114.  
  115.     status_line (MSG_TXT(M_BINK_BEGIN), ANNOUNCE, COMPILER_NAME);
  116.     set_xy ("");
  117.  
  118.     set_prior(4);                                           /* Always High    */
  119.     XON_DISABLE ();
  120.     set_prior(2);                                           /* Regular        */
  121.  
  122.     /* Turn off forced events */
  123.     if (noforce)
  124.         {
  125.         find_event ();
  126.         noforce = 0;
  127.         }
  128.     if (redo_dynam)
  129.         {
  130.         for (j = 0; j < num_events; j++)
  131.             {
  132.             e_ptrs[j].behavior &= ~MAT_SKIP;
  133.             }
  134.         redo_dynam = 0;
  135.         }
  136.  
  137.     /*
  138.      * See if we should exit before initializing the modem (and therefore
  139.      * possibly letting a call sneak through)
  140.      */
  141.  
  142.     find_event ();
  143.     do_ready (MSG_TXT(M_READY_INIT));
  144.  
  145.     /* Make sure we have all necessary parameters and that the nodelist
  146.      * index gets read in. If not, then we must exit right now.
  147.      */
  148.  
  149.     if (!net_params || !nodefind (&boss_addr, 0))
  150.         if (boss_addr.Net != 0xffff)
  151.             {
  152.             status_line (MSG_TXT(M_MISCONFIGURED));
  153.             errl_exit (254);
  154.             }
  155.  
  156.     /* Set up outbound mail */
  157.     list_next_event ();
  158.     set_up_outbound ();
  159.  
  160.     if (!CARRIER)
  161.         {
  162.         mdm_init (modem_init);                              /* Reinit modem   */
  163.         }
  164.  
  165.     blank_timer = timerset ((unsigned int)blank_time);/* Set a timer  */
  166.     init_timer = timerset ((unsigned int)60000);    /* Set a 10 minute timer  */
  167.     t1 = timerset ((unsigned) next_minute ());      /* Set a 1 minute timer   */
  168.     waitfor_line = timerset ((unsigned int)6000);   /* no collisions for 1 min*/
  169.  
  170. top_of_mail:
  171.     un_attended = 1;
  172.     no_inbound = 0;
  173.     m = 1;
  174.  
  175.     /* As long as we don't press a key */
  176. bad_char:
  177.     more_mail = 1;
  178.     while (!(KEYPRESS () || ctrlc_ctr))
  179.         {
  180.         find_event ();
  181. #ifdef MILQ
  182.         if ( hold_hWnd != GetFocus() )
  183.           SendMessage( node_hWnd, WM_COMMAND, GD_LAST, (long)&hist.last_addr );
  184. #endif
  185.         /* Show that we are ready */
  186.         if (m)
  187.             {
  188.             if (fullscreen)
  189.                 {
  190.                 do_ready (MSG_TXT(M_READY_WAITING));
  191.                 list_next_event ();
  192.                 }
  193.             else
  194.                 status_line (MSG_TXT(M_EVENT_WAITING), cur_event + 1);
  195.  
  196.             blank_timer = timerset ((unsigned int)blank_time);/* Set a timer  */
  197.             init_timer = timerset ((unsigned int)60000);/* Set a 10 min timer */
  198.             t1 = timerset ((unsigned) next_minute ());  /* Set a 1 min timer  */
  199.             }
  200.  
  201.         if (timeup (t1))
  202.             {
  203.             put_up_time ();
  204.             list_next_event ();
  205.             t1 = timerset ((unsigned) next_minute ());  /* Set a 1 min timer  */
  206.             }
  207.  
  208.         /* See if blanking interval has elapsed */
  209.         if (timeup (blank_timer))
  210.             {
  211.             blank_tim